{% set webserver_service = (letsencrypt.settings.webserver_service is defined and letsencrypt.settings.webserver_service)
    ? letsencrypt.settings.webserver_service
    : '' %}

<input type="hidden" name="letsencrypt[install]" value="1" />

<div class="container-fluid cm-container-white section-title">
    <h1>Let's Encrypt</h1>

    <p>Let’s Encrypt is a new Certificate Authority</p>
</div>

<div id="letsencrypt-container"
     class="container-fluid collapse in">
    <div class="panel panel-default">
        <div class="panel-body">
            <input type="hidden" name="letsencrypt[settings][webserver_service]" value="{{ webserver_service }}" />

            <div class="form-group col-xs-12 col-sm-6">
                <label for="letsencrypt-settings-email">
                    Admin Email Address
                </label>
                <input type="email" id="letsencrypt-settings-email"
                       name="letsencrypt[settings][email]"
                       placeholder="you@awesome" class="form-control"
                       value="{{ letsencrypt.settings.email }}" />
                <div class="help-block">
                    <p>This email address will be displayed as the admin for your
                        generated certificates</p>
                </div>
            </div>

            <div class="clearfix"></div>

            <div class="help-block col-xs-12">
                <p>The domains chosen below must match up with the domains you
                    have selected to use Let's Encrypt SSL certificates in either
                    the Nginx or Apache tabs!</p>

                <p>A cron job is made to automatically renew your certificate(s).</p>
            </div>
        </div>

        <div class="clearfix"></div>
    </div>

    <div class="clearfix"></div>

    <div class="panel panel-primary">
        <div class="panel-heading">Domains</div>
        <div class="panel-body">
            <ul class="nav nav-tabs nested-tabs sortable">
                <li class="add">
                    <a href="{{ path('puphpet.letsencrypt.add_domain') }}"
                       data-toggle="add-block">
                        <i class="fa fa-plus"></i> Add</a>
                </li>
                {% for index, domain in letsencrypt.domains %}
                    {% set blockId = "letsencrypt-domains-#{index}" %}
                    {% set blockName = "letsencrypt[domains][#{index}]" %}
                    <li class="{{ loop.first ? 'active' }}">
                        <a href="#" data-target="#{{ blockId }}"
                           data-toggle="tab">{{ index }}</a>
                        <div class="btn-group">
                            <button type="button" class="btn btn-default"
                                    data-toggle="delete-block"
                                    data-target="#{{ blockId }}">
                                <i class="fa fa-close"></i></button>
                        </div>
                        <input type="hidden" name="{{ blockName }}" value="1" />
                    </li>
                {% endfor %}
            </ul>

            <div class="tab-content">
                <div class="empty-tabs">
                    <i class="fa fa-share fa-rotate-270" aria-hidden="true"></i>
                    Click to add a host
                </div>
                {% for index, domain in letsencrypt.domains %}
                    {% include 'PuphpetBundle:letsencrypt:domain.html.twig' with {
                        'uniqid': index,
                        'active': loop.first ? true : false,
                    } %}
                {% endfor %}
            </div>
        </div>
    </div>

    <div class="clearfix"></div>
</div>

<div class="container-fluid cm-container-white section-footer">
    <a href="#apache" data-toggle="tab" class="btn btn-primary btn-lg pull-left">
        <i class="fa fa-arrow-left" aria-hidden="true"></i>
        Apache
    </a>

    <a href="#php" data-toggle="tab" class="btn btn-primary btn-lg pull-right">
        PHP
        <i class="fa fa-arrow-right" aria-hidden="true"></i>
    </a>
</div>
